package com.hgy.carsb.controller;

import com.hgy.carsb.entity.ProfitTotalDetail;
import com.hgy.carsb.service.ProfitTotalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ProfitTotalController {
    @Autowired
    private ProfitTotalService profitTotalService;

    private int year = 2020;
    private int month = 4;
    @GetMapping("/profittotal")
    @ResponseBody
    public List<ProfitTotalDetail> getDetail(){
        List<ProfitTotalDetail> ans = new ArrayList<>();
        String[] company = {"FAWVOLKSWAGEN", "FAWCARCO", "FAWXL", "FAWJF", "FAWKC", "FAWMC", "FAWWL", "FAWMJ", "FAWDZ",
                            "FAWHNSY", "FAWJY", "FAWKJ", "FAWTR", "FAWFB", "FAWEI", "FAWBS", "FAWAO", "FAWCT", "FAWTC",
                            "FAWXY", "FAWTH", "FAWFW", "FAWFM", "FAWQM", "FAWSY"};
        for (int i=0; i<company.length; i++){
            ans.add(profitTotalService.getDetail(year, month, "interest", "income", company[i]));
            ans.add(profitTotalService.getDetail(year, month, "interest", "right", company[i]));
        }
        return ans;
    }
}
